﻿using Microsoft.Practices.Unity.InterceptionExtension;
using Microsoft.Practices.Unity.ObjectBuilder;

namespace TSharp.Core.Aop.PolicyInjectionIntegrated
{
    /// <summary>
    /// 
    /// <para>by tangjingbo at 2009/12/11 22:35</para>
    /// </summary>
    public class ExtendedInterception : Interception
    {
        /// <summary>
        /// 
        /// <para>by tangjingbo at 2009/12/11 22:35</para>
        /// </summary>
        public ExtendedInterception()
        {
            Interceptor = new TransparentProxyInterceptor();
        }

        /// <summary>
        /// 
        /// <para>by tangjingbo at 2009/12/11 22:35</para>
        /// </summary>
        /// <value></value>
        public IInterceptor Interceptor { get; internal set; }

        /// <summary>
        /// 
        /// <para>by tangjingbo at 2009/12/11 22:35</para>
        /// </summary>
        protected override void Initialize()
        {
            Context.Strategies.Add(new ExtendedInstanceInterceptionStrategy(this), UnityBuildStage.Setup);
            Context.Strategies.Add(new ExtendedTypeInterceptionStrategy(this), UnityBuildStage.PreCreation);
            Context.Container.RegisterInstance<InjectionPolicy>(typeof (AttributeDrivenPolicy).AssemblyQualifiedName,
                                                                new AttributeDrivenPolicy());
        }
    }
}